package com.e7.service;

import org.springframework.stereotype.Service;

import com.e7.common.Constants;
import com.e7.model.User;
import com.e7.util.Encoder;
import com.opensymphony.xwork2.ActionContext;

@Service("validater")
public class ValidateService {
	public boolean isEmpty(String... args) {
		for (String arg : args) {
			if (arg == null || arg.trim().equals("")) {
				return true;
			}
		}
		return false;
	}

	public boolean exists(String field, String value) {

		return false;
	}

	public Integer validateEmail(String value) {
		// TODO Auto-generated method stub
		return -1;
	}

	public Integer validatePhone(String value) {
		// TODO Auto-generated method stub
		return -1;
	}

	public Integer validateName(String value) {
		// TODO Auto-generated method stub
		return -1;
	}

	public boolean isValidPassword(String password) {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean isValidEmail(String value) {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean isValidPhone(String value) {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean isValidNickName(String value) {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean checkCaptcha(String captcha) {
		String c = (String) ActionContext.getContext().getSession()
				.get("captcha");
		if (c.equals(captcha.trim())) {
			return true;
		}
		return false;
	}

	public boolean doMap(String contact, String code, String tm) {
		String c = Encoder.encode(contact + Constants.Key.CTCTKEY + tm);
		if(c.equals(code))
			return true;
		return false;
	}

	public boolean verifyContact(User user) {
		// TODO Auto-generated method stub
		return false;
	}
}
